jQuery(document).ready(function($) {
$("#header").load("/job/topul.html");
var resumeDetailId="";
//所有个人简历的显示开始
        $.ajax({
            url : "/job/resume/getResumeByUid",
            async : false,
            type : "GET",
            contentType : 'application/json',
            dataType : 'json',

            success : function(data) {
                let contentdata=data.data;
                 $("#databody").empty();
   for(var i=0;i<contentdata.length;i++){
       $("#databody").append("  <tr >");

         $("#databody").append(" <td>"+contentdata[i].id+"</td>");
          $("#databody").append(" <td>"+contentdata[i].resumename+"</td>");
     $("#databody").append(" <td><button type='button' name='resumedeatilslook' id='resumedetails"+contentdata[i].id+"' class='btn btn-outline-primary btn-sm'>查看详情</button>&nbsp&nbsp&nbsp<a  type='button' name='exportresume' class='btn btn-outline-primary btn-sm' href='"+contentdata[i].wordPath+"' id='export"+contentdata[i].id+"'>导出简历</a>&nbsp&nbsp&nbsp<button  type='button' name='deleteresume' class='btn btn-outline-danger btn-sm' id='delete"+contentdata[i].id+"'>删除简历</button></td>");
       $("#databody").append(" </tr>");
   }
  // 删除简历开始
$("button[name='deleteresume']").click(function(){
let resumeDeletedId=$(this).attr("id").substr(6);
console.log(resumeDeletedId);
if(confirm("确认删除吗？")){
$.post("/job/resume/deleteResume/"+resumeDeletedId,function(data){
if(data.msg=="成功"){
alert("删除成功！");
window.location.href="/job/resumeList.html";
}else alert("删除失败！")
});


}else{console.log("取消删除")};
});
  // 删除简历结束
 // 查看详情
$("button[name='resumedeatilslook']").click(function(){
 resumeDetailId=$(this).attr("id").substr(13);
$.get("/job/resume/getResumeByResumeId/"+resumeDetailId,function(data){
let contentdata=data.data;
//    $("#morebody").append("<div class='row'><div class='col-lg-6'><section class='card'><div class='card-body text-secondary'>"+contentdata.name+"</div></section></div><div class='col-lg-6 '><section class='card'><div class='card-body text-secondary'>"+contentdata.sex+"</div></section></div></div>");
$("#morebody").append("<div class='content'><div class='row form-group ' ><div class='col col-md-2'> <label class='control-label mb-1'>简历名称</label></div><div class='col col-md-4'> <p>"+contentdata.resumename+"</p></div><div class='col col-md-2'> <label class='control-label mb-1'>姓名</label></div><div class='col col-md-4'> <p>"+contentdata.name+"</p></div></div><div class='row form-group ' ><div class='col col-md-2'><label class='control-label mb-1'>性别</label></div><div class='col col-md-4'> <p>"+contentdata.sex+"</p></div><div class='col col-md-2'><label class='control-label mb-1'>民族</label></div><div class='col col-md-4'> <p>"+contentdata.nation+"</p></div></div><div class='row form-group ' ><div class='col col-md-2'> <label class='control-label mb-1'>邮编</label></div><div class='col col-md-4'> <p>"+contentdata.emailaddress+"</p></div><div class='col col-md-2'><label class='control-label mb-1'>手机号</label></div><div class='col col-md-4'> <p>"+contentdata.mobile+"</p></div></div><div class='row form-group ' ><div class='col col-md-2'> <label class='control-label mb-1'>专业</label></div><div class='col col-md-4'> <p>"+contentdata.major+"</p></div><div class='col col-md-2'><label class='control-label mb-1'>学历</label></div><div class='col col-md-4'> <p>"+contentdata.education+"</p></div></div><div class='row form-group ' ><div class='col col-md-2'> <label class='control-label mb-1'>出生日期</label></div><div class='col col-md-4'> <p>"+contentdata.born+"</p></div></div><div class='row form-group ' ><div class='col col-md-2'> <label class='control-label mb-1'>通信地址</label></div><div class='col col-md-10'><p>"+contentdata.address+"</p></div></div><div class='row'><div class='form-group'><label class='control-label mb-1'>工作经历</label><p>"+contentdata.workedyears+"</p></div><div class='form-group'><label class='control-label mb-1'>个人证书</label><p>"+contentdata.certificate+"</p></div><div class='form-group'><label class='control-label mb-1'>培训经历</label><p>"+contentdata.trainExp+"</p></div></div><div class='row'><div class='form-group'><label class='control-label mb-1'>自我评价</label><p>"+contentdata.assessment+"</p></div><div class='form-group'><label class='control-label mb-1'>项目经历</label><p>"+contentdata.projectExp+"</p></div></div><div class='row form-group'><div class='col col-md-3'><label for='file-input' class=' form-control-label'>照片</label></div><div class='col-12 col-md-9'><img src='"+contentdata.image1+"' /></div></div></div>");

//    $("#morebody").append("<li>头像</li>");
//    $("#morebody").append("<img src='"+contentdata.image1+"' />");
//    $("#morebody").append("<li>姓名</li>");
//    $("#morebody").append("<p>"+contentdata.name+"</p>");
//    $("#morebody").append("<li>性别</li>");
//    $("#morebody").append("<p>"+contentdata.sex+"</p>");
//    $("#morebody").append("<li>民族</li>");
//    $("#morebody").append("<p>"+contentdata.nation+"</p>");
//    $("#morebody").append("<li>邮编</li>");
//    $("#morebody").append("<p>"+contentdata.emailaddress+"</p>");
//    $("#morebody").append("<li>手机号</li>");
//    $("#morebody").append("<p>"+contentdata.mobile+"</p>");
//    $("#morebody").append("<li>专业</li>");
//    $("#morebody").append("<p>"+contentdata.major+"</p>");
//    $("#morebody").append("<li>学历</li>");
//    $("#morebody").append("<p>"+contentdata.education+"</p>");
//    $("#morebody").append("<li>出生日期</li>");
//    $("#morebody").append("<p>"+contentdata.born+"</p>");
//    $("#morebody").append("<li>通信地址</li>");
//    $("#morebody").append("<p>"+contentdata.address+"</p>");
//    $("#morebody").append("<li>工作经历</li>");
//    $("#morebody").append("<p>"+contentdata.workedyears+"</p>");
//    $("#morebody").append("<li>个人证书</li>");
//    $("#morebody").append("<p>"+contentdata.certificate+"</p>");
//    $("#morebody").append("<li>工作经历</li>");
//    $("#morebody").append("<p>"+contentdata.workedyears+"</p>");
//    $("#morebody").append("<li>工作经历</li>");
//    $("#morebody").append("<p>"+contentdata.workedyears+"</p>");
});
$("#resumedetailsshow").modal("show");
});

// 查看详情
            }
        });
//所有个人简历的显示结束
//简历可修改开始
 $("#currentcreatenewresume2").on("click", function(){
        $("#resumedddetails :input").attr("disabled", false);
        $("#resumedddetails :textarea").attr("disabled", false);
        $("#confirmchangeBTN").attr("disabled", false);
    });
//简历可修改结束
//修改简历开始
$("#confirmchangeBTN").click(function(){
if(confirm("确认修改吗？")){
let newResumeData={
                   name:$("#resumename2").val(),
                  nation :$("#nationname2").val(),
                    address:$("#resumeaddress2").val(),
                    mailOrder:$("#resumemailaddress2").val(),
                 bornDate :$("#borndate2").val(),
                  education :$("#resumemeducation2").val(),
                   profession:$("#resumeprofession2").val(),
                  mobile :$("#resumemobile2").val(),
                   sex:$("#resumesex2").val(),
                  assessment :$("#resumeassessment2").val(),
                   certificate:$("#resumemcertificate2").val(),
                   workedyears:$("#resumemworkedyears2").val(),
                  projectExp :$("#resumeprojectExp2").val(),
                  id:resumeDetailId,
                  trainExp :$("#resumetrainExp2").val()};
 $.ajax({
            url : "/job/resume/updateResume",
            async : false,
            type : "POST",
            contentType : 'application/json',
            dataType : 'json',
            data :JSON.stringify(newResumeData),
            success : function(data) {
              if(data.msg=="成功"){
              alert("修改成功！");
              window.location.href="resumeList.html";
              }else alert("修改失败！")
            }
        });
}else console.log("取消修改");


});
//修改简历结束
////创建简历开始
////拿当前登录用户的id开始
//var currentUserId="";
//
//
//        $("#currentcreatenewresume").click(function(){
//        let data={name:$("#resumename").val(),
//        nation:$("#nationname").val(),
//        address:$("#resumeaddress").val(),
//        mailOrder:$("#resumemailaddress").val(),
//        bornDate:$("#borndate").val(),
//        education:$("#resumemeducation").val(),
//        profession:$("#resumeprofession").val(),
//        mobile:$("#resumemobile").val(),
//        sex:$("#resumesex").val(),
//        assessment:$("#resumeassessment").val(),
//        certificate:$("#resumemcertificate").val(),
//        workedyears:$("#resumemworkedyears").val(),
//        projectExp:$("#resumeprojectExp").val(),
//        createBy:currentUserId,
//        trainExp:$("#resumetrainExp").val() }
//
//         $.ajax({
//                    url : "resume/addResume",
//                    async : false,
//                    type : "POST",
//                    contentType : 'application/json',
//                    dataType : 'json',
//                    data :JSON.stringify(data),
//                    success : function(data) {
//                        if("成功"==data.msg){
//                        alert("简历创建成功！");
//                        window.location.href="resumeList.html";
//                        }else alert("简历创建失败！");
//                    }
//                });
//
//                   //上传头像开始
////         $("#formId").submit();
//        //上传头像结束
//});
////创建简历结束


    $("#newResumebtn").click(function(){
         $("#resumedddetailsform").submit();
    });
});